﻿<?php
include_once ('../inc/db.php');
include_once ('../inc/user.inc.php');
$message = '';
$username = '';
$userid = '';
$error = '';
$username = @$_POST['username'];
$username = urldecode($username);
$password = @$_POST['pwd'];

$User=new User();
$userI=$User->getUserInfo($username);
if($userI){
	$pwd = $userI['upassword']; //将该用户的密码取出后赋给$PWD变量
	$key_password = md5($password);			
	if ($key_password == $pwd )  //crypt()函数用于增加被编码字符数目的字符串，以使编码更加安全。
	{		
			$success = true;          //把真赋SESSION的isLogin变量
			$message = "登录成功";
			$userid = $userI['u_id'];   //用户ID赋给SESSION的s_UID变量	
	}else{	
		$success = false;
		$error = '用户名或密码错误！';			
	}			
}else{
	$success = false;
	$error = '用户名错误！';	
}
$dateatter = array("success"=>$success,"message"=>$message,"error"=>$error,"username"=>$username,"userid"=>$userid);
echo json_encode($dateatter);
?>
